﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Script.Serialization;

namespace Sausage.Web.Models
{
    /// <summary>
    /// 养护计划模型
    /// </summary>
    public class MaintainPlanListRow
    {
        /// <summary>
        /// 获得或者设置计划编号。
        /// </summary>
        /// <value>
        /// 计划编号。
        /// </value>
        /// <remarks></remarks>
        /// <history>
        /// [ZengE]               2012/3/15 21:44    创建
        /// </history>
        public Guid PlanID
        {
            get;
            set;
        }

        public Guid OrganizationID
        {
            get;
            set;
        }

        public string Organization
        {
            get;
            set;
        }

        public DateTime CreateDate
        {
            get;
            set;
        }

        public string Applicant
        {
            get;
            set;
        }

        public DateTime ApplicationDate
        {
            get;
            set;
        }

        public Decimal Amount
        {
            get;
            set;
        }

        public string Auditor
        {
            get;
            set;
        }

        public DateTime? AuditedDate
        {
            get;
            set;
        }

        public string Approver
        {
            get;
            set;
        }

        public DateTime? ApprovedDate
        {
            get;
            set;
        }

        public int State
        {
            get;
            set;
        }

        public bool IsDelay
        {
            get;
            set;
        }

        public string Memo
        {
            get;
            set;
        }

        /// <summary>
        /// 获得或者设置养护计划项目原始数据。
        /// </summary>
        /// <value>
        /// 养护计划项目原始数据。
        /// </value>
        /// <remarks></remarks>
        /// <history>
        /// [ZengE]               2012/3/15 22:23    创建
        /// </history>
        public string ItemsRaw
        {
            get;
            set;
        }

        /// <summary>
        /// 获得养护计划项目。
        /// </summary>
        /// <value>
        /// 养护计划项目。
        /// </value>
        /// <remarks></remarks>
        /// <history>
        /// [ZengE]               2012/3/15 22:23    创建
        /// </history>
        public MaintainPlanItemListRow[] Items
        {
            get
            {
                //判断数据是否已经初始化
                if (null == this.m_Items)
                {
                    //判断是否设置了原始数据
                    if (string.IsNullOrEmpty(this.ItemsRaw))
                    {
                        //设置为空数组
                        this.m_Items = new MaintainPlanItemListRow[0];
                    }
                    else
                    {
                        //创建序列化器
                        JavaScriptSerializer serializer = new JavaScriptSerializer();

                        //反序列化数据
                        this.m_Items = serializer.Deserialize<MaintainPlanItemListRow[]>(this.ItemsRaw);
                    }
                }

                //返回数据
                return this.m_Items;
            }
            set
            {
                this.m_Items = value;
            }
        }

        #region ---Field

        /// <summary>
        /// 养护计划项目。
        /// </summary>
        /// <remarks></remarks>
        /// <history>
        /// [ZengE]               2012/3/15 22:24    创建
        /// </history>
        private MaintainPlanItemListRow[] m_Items;

        #endregion
    }
}
